package com.kky.pp.popup

import android.content.Context
import android.widget.ImageView
import android.widget.TextView
import com.kky.pp.R
import com.kky.pp.view.date.DateSelectView
import razerdp.basepopup.BasePopupWindow

class SelectDataPopup(var ctx: Context, var nowDate: String, var callback: OnCallBack) :
    BasePopupWindow(ctx) {
    init {
        setContentView(R.layout.popup_new_select_date)
        initView()
    }

    private fun initView() {
        val imgBack = findViewById<ImageView>(R.id.imgViewPopupSelectBirthBack)
        imgBack.setOnClickListener {
            dismiss()
        }
        val bntSave = findViewById<TextView>(R.id.txtPopupSelectBirthSave)
        val viewDateSelect = findViewById<DateSelectView>(R.id.dateViewPopupSelectBirth)
        if (nowDate.isNotEmpty())
            viewDateSelect.initDate(nowDate)
        bntSave.setOnClickListener {
            callback.callBack(viewDateSelect.getSelectDate())
            dismiss()
        }
        setOutSideDismiss(true)
    }

    interface OnCallBack {
        fun callBack(date: String)
    }
}